Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement TX v4 experimental #1201

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft

Conversation

jptosso
Copy link
Member

@jptosso jptosso commented Nov 6, 2024

Thank you for contributing to Coraza WAF, your effort is greatly appreciated
Before submitting check if what you want to add to coraza list meets quality standards before sending pull request. Thanks!

Make sure that you've checked the boxes below before you submit PR:

Thanks for your contribution ❤️

@jptosso jptosso requested a review from a team as a code owner November 6, 2024 15:35
@jptosso jptosso marked this pull request as draft November 6, 2024 15:35
@jptosso jptosso added the v4 Work for v4 label Nov 6, 2024
"github.com/corazawaf/coraza/v3/types"
)

type Transaction interface {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO this interface is meaningless, if someone wants to access this fields they can create their own convenience interface.

Copy link
Member Author

@jptosso jptosso Nov 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

package test

import (
	"context"
	"testing"

	"github.com/corazawaf/coraza/v3"
	"github.com/corazawaf/coraza/v3/types"
)

type transaction interface {
	types.Transaction
	Context() context.Context
}

func TestCoraza(t *testing.T) {
	waf, _ := coraza.NewWAF(coraza.NewWAFConfig())
	tx, ok := waf.NewTransaction().(transaction)
	if !ok {
		t.Errorf("cannot access Token")
	}
	tx.Context().Value("key")
}

It is not possible to access internal fields using this hack

Context IS required to control timeout for certain actions, among others

@@ -1576,6 +1576,14 @@ func (tx *Transaction) String() string {
return res.String()
}

func (tx *Transaction) UnixTimestamp() int64 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is controversial and that is why I'd like to use use cases before exposing this. Why not a time.Time? Not saying that is the answer, just saying we need concrete use cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
v4 Work for v4
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants